$(function () {
    let id=localStorage.getItem("updataById");
    userFindById(id);
})
var groupCode;
function userFindById(id){
    let da={
        id:id,
    }
    let data=myAjax("/user/findById",da,"post");
    if (data.code){
        alert("没有相关权限");
    }else {
        data=data.userbean;
        $("#code").val(data.code);
        // $('#userType option[value=' + data.typeCode + ']').attr('selected',true);//下拉框选择器
        $("#name").val(data.name);
        $("input[name='sex'][value="+data.sex+"]").attr("checked",true);
        $("#age").val(data.age);
        $("#education").val(data.education);
        $("#university").val(data.university);
        $("#naative").val(data.naative);
        $("#address").val(data.address);
        $("#phone").val(data.phone);
        $("#otherphone").val(data.otherphone);
        $("#groupCode").val(data.groupCode);
        $("#timeAdmission").val(data.timeAdmission);
        $("#frequency").val(data.frequency);
        $("#classroom").val(data.classroom);
        $("#position").val(data.position);
    }
    groupCode=data.groupCode;
}

function userUpdate() {
    let da={
        id:localStorage.getItem("updataById"),
        code:$("#code").val(),
        // typeCode:$("#userType").val(),
        name:$("#name").val(),
        sex:$("input[name='sex']:checked").val(),
        age:$("#age").val(),
        education:$("#education").val(),
        university:$("#university").val(),
        naative:$("#naative").val(),
        address:$("#address").val(),
        phone:$("#phone").val(),
        otherphone:$("#otherphone").val(),
        groupCode:groupCode,
        timeAdmission:$("#timeAdmission").val(),
        frequency:$("#frequency").val(),
        classroom:$("#classroom").val(),
        position:$("#position").val(),
        frontGroupCode:$("#groupCode").val(),
    };
    if (da.groupCode!=da.frontGroupCode){
        myAjax("/user/adjustmentGroupRecordAdd",da,"post");
    }
        let data=myAjax("/user/update",da,"post");
    data=data.result;
    if (data==1){
        alert("修改成功!");
        $('#middle-reght').load('user/user.html');
    }else {
        alert("修改失败!");
    }
}
